package com.xiangban.yanglaodajie_platform.controller;

import com.xiangban.yanglaodajie_platform.aop.Permission;
import com.xiangban.yanglaodajie_platform.entity.Goods;
import com.xiangban.yanglaodajie_platform.entity.ShoppingCart;
import com.xiangban.yanglaodajie_platform.entity.res.ApiResult;
import com.xiangban.yanglaodajie_platform.service.GoodsService;
import com.xiangban.yanglaodajie_platform.utils.JsonData;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author Mr. MaYaYun
 * @Data 2021/3/15 16:55
 */
@RequestMapping("/api/goods")
@RestController
@Api(tags = "（软件）商品控制台")
public class GoodsController {

    @Autowired
    private GoodsService goodsService;

    @PostMapping("/getPage")
    @ApiOperation("商品分页")
//    @Permission
    public JsonData getPage(@RequestBody ShoppingCart shoppingCart){
       return JsonData.buildSuccess(goodsService.getPage(shoppingCart),"成功获取");
    }

//    @PostMapping("/shopGoods")
//    @ApiOperation("店铺商品列表(商家端)")
//    @Permission(type = "shop")
//    public ApiResult shopGoods(){
//        return ApiResult.newSuccess(goodsService.shopGoods());
//    }

    @PostMapping("/alterGoods")
    @ApiOperation("更改上下架、库存(商家端)")
    @Permission(type = "shop")
    public ApiResult alterGoods(Goods goods){
        goodsService.alterGoods(goods);
        return ApiResult.newSuccess();
    }



}
